public class test {
    //直接插入排序
    public void insetsort(int[] array) {
        for (int i = 1; i <array.length ; i++) {
            int tmp = array[i];
            int j = i - 1;
            for (; j > 0; j--) {
                if (array[j] > tmp) {
                    array[j + 1] = array[j];
                } else {
                    array[j + 1] = tmp;
                    break;
                }
                array[j + 1] = tmp;

            }
        }
    }
    //希尔排序
    public void shellsort(int[] array) {
        int gap = array.length;
        while(gap != 0){
            gap /= 2;
            shell(gap,array);
        }
    }
    private void shell(int gap,int[] array) {
        for (int i = gap; i < array.length; i++) {
            int tmp = array[i];
            int j = i-gap;
            for (; j >=0; j-=gap) {
                if(array[j]>tmp){
                    array[j+gap] = array[j];
                }else{
                    array[j+gap] = tmp;
                    break;
                }
            }
            array[j+gap] = tmp;
        }
    }
    public static void main(String[] args) {

    }
}
